﻿// File: ProductInfoControl.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;

namespace WpfPTest
{
    public partial class ProductInfoControl : UserControl
    {
        public event Action<string> MessageSent;
        public string Position { get; set; }
        public ProductInfoControl()
        {
            InitializeComponent();
        }

        public string ProductName
        {
            get { return ProductNameTextBlock.Text; }
            set { ProductNameTextBlock.Text = value; }
        }

        public string ProductIndex
        {
            get { return IndexTextBlock.Text; }
            set { IndexTextBlock.Text = value; }
        }
        public void ReceiveMessage(string message)
        {
            MessageTextBlock.Text = message;
        }

        private void OnSendMessageClick(object sender, RoutedEventArgs e)
        {
            MessageSent?.Invoke($"{ProductName} (位置: {Position}): 消息来自 {Guid.NewGuid()}");
        }
    }
}
